package com.whut.customer.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 *  Swagger2配置
 */
@Configuration
@EnableSwagger2
@Profile({"dev","test","int","local"})
public class Swagger2Config {

    //访问地址：http://localhost:port/your-app-root/swagger-ui.html
    //eg：http://localhost:8765/admin/swagger-ui.html
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.whut.customer.controller"))
                .paths(PathSelectors.any())
                .build();
                //配置全局亲求参数
                //.globalOperationParameters(pars);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("whut-智能跑道系统接口文档")
                .description("whut-客户端接口文档")
                .version("1.0")
                .build();
    }
}
